import React, {useContext, useState} from "react";
import {A} from "./a";
import {B} from "./b";

export const TestContext = React.createContext({userName: "", color1: '', color2: ''})
export const StudyUseContext = () => {
	const [user, setUser] = useState({userName: "小胖", color1: 'pink', color2: 'yellow'})
	const change1 = () => {
		setUser({...user, color1: 'blue'})
	}
	return <TestContext.Provider value={user}>
		<A/>
		<B/>
		<button onClick={() => change1()}>改变颜色</button>
	</TestContext.Provider>
}
